package day17_Inet.demo07_TCP;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server_TCP {
    public static void main(String[] args) throws Exception{
        ServerSocket serverSocket = new ServerSocket(8888);
        Socket accept = serverSocket.accept();
        //接收数据
        InputStream is = accept.getInputStream();
        byte[] bytes = new byte[1024];
        int i = is.read(bytes);
        System.out.println(new String(bytes,0,i));
        //发送数据
        OutputStream os = accept.getOutputStream();
        String s="hahaha";
        os.write(s.getBytes());
        accept.close();
    }
}
